﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using TinyERP.Framework.Controls;
using TinyERP.Framework;

namespace TinyERP.View
{
    public partial class CustomerSearchBar : BaseSearchBar
    {
        public CustomerSearchBar()
        {
            InitializeComponent();
            this.findButton.Click += new EventHandler(OnFindClick);
        }

        void OnFindClick(object sender, EventArgs e)
        {
            if (SearchHandler != null)
            {
                SearchHandler.OnFind();
            }
        }
        public string SearchBy
        {
            get
            {
                return (string) cbSearchBy.SelectedValue;
            }
            
        }
        public override string SearchValue
        {
            get
            {
                return this.txtDefaultSearchField.Text.Trim();
            }
            set
            {
                this.txtDefaultSearchField.Text = value;
            }
        }

        protected override void OnLoad(EventArgs e)
        {
            IList<ListItemData> listCriteria = new List<ListItemData>();
            listCriteria.Add(new ListItemData(ModuleResourceManager.GetInstance().
                GetStringFromModuleResourceKey("SearchByFirstName, TinyERP.ERP"),
                "FirstName"));
            listCriteria.Add(new ListItemData(ModuleResourceManager.GetInstance().
                GetStringFromModuleResourceKey("SearchByLastName, TinyERP.ERP"),
                "LastName"));
            listCriteria.Add(new ListItemData(ModuleResourceManager.GetInstance().
                GetStringFromModuleResourceKey("SearchByEmail, TinyERP.ERP"),
                "Email"));
            listCriteria.Add(new ListItemData(ModuleResourceManager.GetInstance().
                GetStringFromModuleResourceKey("SearchByPhoneNumber, TinyERP.ERP"),
                "PhoneNumber"));
            this.cbSearchBy.DisplayMember = "Text";
            this.cbSearchBy.ValueMember = "Value";
            this.cbSearchBy.DataSource = listCriteria;
        }
    }
    
}
